<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1.0"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="telephone=no" name="format-detection"/>
    <title>设置新密码</title>
    <link rel="stylesheet" href="css/H-ui.reset.css">
    <link rel="stylesheet" href="css/tongyong.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/alert.css">
    <link rel="stylesheet" href="css/myStyle.css">
</head>
<body>
	
	<div class="setting_div">
		<a href="passwd_find.html"><img class="back_img" src="images/back.png"></a>
		<span>设置新密码</span>
	</div>
	
	<p class="captcha_top_line"><span>已发送六位短信验证码</span></p>
	<div class="getCapRow">
		<label>验证码 </label>
		<input class="flexLong" id="code" type="text" maxlength="6" placeholder="请输入验证码" />
	</div>
	<p class="setting_spacing_line"></p>
	<div class="getCapRow">
		<label>新密码</label>
		<input id="password" type="password" maxlength="20" placeholder="请输入6-20位登录密码">
	</div>
	<p class="setting_spacing_line"></p>
	<div class="repasswd">
		<label>再次输入</label>
		<input id="newPassword" type="password" maxlength="20" placeholder="再次输入用于确认">
	</div>
	<p class="setting_top_line"></p>
	
	<div class="submit_div"><button class="submit_btn" id="resetPasswd">下一步</button></div>
	
	<script src="//cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="js/config.js"></script>
	<script type="text/javascript" src="js/alert.js"></script>
	<script type="text/javascript">
		//修改密码
		$("#resetPasswd").click(function(){
			var phoneNo = localStorage.getItem("mobileNo");
			var code = $("#code").val();
			var password = $("#password").val();
			var newPassword = $("#newPassword").val();
			
			if (code == null || code.length == 0) {
				alert("验证码不能为空");
				return false; 
			}
			if (password == null || password.length == 0) {
				alert("密码不能为空");
				return false; 
			}
			if (newPassword == null || newPassword.length == 0) {
				alert("确认密码不能为空");
				return false; 
			}
			var myreg = /^[0-9A-Za-z]{6,20}$/;   //6-20位数字字母组合
			if(!myreg.test(password) || !myreg.test(newPassword)) 
			{ 
			    alert('密码为6-20位数字字母组合,请输入有效密码！'); 
			    return false; 
			}
			if (password != newPassword){
				alert("两次输入的密码不一样");
				return false;
			}
			
			var data = {
						"params": {
			       			 phoneNo: phoneNo,
			       			 code: code,
			       			 newPassword: newPassword
			   			 }
				   		}
			var jsonData = JSON.stringify(data);
			$.ajax({
				url: urlLink + "/bMaMarketCustInfo/resetPassword",
				type: "POST",
				contentType: "application/json; charset=utf-8",
				data:jsonData,
				success:function(data){
					if (data.code == "0000"){
						alert("密码找回成功");
						window.location.href = "login.html";
					}else{
						alert(data.msg);
					}
				},
				error: function(data){
					alert("服务器繁忙");
				}
			})
	
		});
	</script>
</body>
</html>
